package cn.intotw.rdcj.user.fallback;
import cn.intotw.rdcj.core.bean.CommonErrors;
import cn.intotw.rdcj.core.bean.Result;
import cn.intotw.rdcj.user.dto.UserDto;
import cn.intotw.rdcj.user.api.RdcjUserApi;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class RdcjUserFallbackFactory implements FallbackFactory<RdcjUserApi> {
    @Override
    public RdcjUserApi create(Throwable throwable) {
        return new RdcjUserApi() {
            @Override
            public Result<UserDto> getUserInfo(Long userId) {
                return new Result(CommonErrors.SERVICE_UNAVAILABLE.getCode(), "fallback cause = " + throwable.getMessage());
            }
        };
    }
}